<%- @page_title = _('Viewing Group "%s" for Class %s', h(@group.name), h(@teaching.title)) -%>
<h2><%= h(@group.name) %> for <%= h(@teaching.title) %>
  <%- if(@logged_user.is_teacher? || @group.is_owner?(@logged_user)) -%>
    <span class="quick-tip"><%= link_to(_('Edit'), edit_group_path(@project, @teaching, @group)) %></span>
  <%- end -%>
</h2>
<%- unless @group.users.empty? -%>
<h3>Students:</h3>
<ul>
  <%- @group.users.each do |u| -%>
    <li id="user-<%= u.id %>">
      <%= h(u.name) %>
      <%- if((@logged_user.is_teacher? || @group.is_owner?(@logged_user)) && !@group.is_owner?(u)) -%>
        <span class="quick-tip">
          <%= link_to_remote(_("Remove from group"),
                            {:url => remove_user_group_path(@project, @teaching, @group),
                            :confirm => _("Are you sure you want to remove this user from the group?"),
                            :method => :delete,
                            :with => "'user_id=#{u.id}'",
                            :loading => "show_loader(); Element.hide('delete-user-#{u.id}');",
                            :complete => "hide_loader();",
                            :failure => "ajax_error('#{_("Unable to delete user from group")}'); Element.show('delete-user-#{u.id}');",
                            :success => "new Effect.Fade('user-#{u.id}');"},
                            :id => "delete-user-#{u.id}",
                            :href => confirm_remove_user_group_path(:project_id => @project, :class_id => @teaching, :id => @group, :user_id => u.id)) %>
        </span>
      <%- end -%>
    </li>
  <%- end -%>
</ul>
<%- else -%>
<p>No user has joined this group, yet.</p>
<%- end -%>
<%= link_to(_("View files"), uploads_path(@project, @teaching, @group)) %>
<%- if @logged_user.is_teacher? -%>
  <hr />
  <%- form_tag(group_path(@project, @teaching, @group),
                :method => :delete,
                :onsubmit => "if(confirm('#{_('Are you sure you want to delete this group?')}')){Field.disable('submit-form'); return true;}else{return false;}") do -%>
    <%= submit_tag(_('Delete this group'),
                    :class => 'button',
                    :id => 'submit-form') %>
  <%- end -%>
<%- end -%>
<hr />
<%= link_to(_("&laquo; Back to class"), class_path(@project, @teaching)) %>
<%- if @logged_user.is_teacher? -%>
<br />
  <%= link_to(_("&laquo; View all groups"), groups_path(@project, @teaching)) %>
<%- end -%>

<%- content_for :sidebar do -%>
  <h3><%= _("Deadlines") %>:</h3>
  <%- unless @group.teaching.deadlines.empty? -%>
    <ul>
      <%- @teaching.deadlines.each do |d| -%>
        <li><strong<%= d.is_expired? ? ' class="warning"' : '' %>><%= d.end.formatted %></strong>:<br />
        <%= link_to(h(d.title), deadline_path(@project, @teaching, d)) %></li>
      <%- end -%>
    </ul>
  <%- else -%>
    <p><%= _("No deadline has been set, yet. Lucky you!") %></p>
  <%- end -%>
<%- end -%>